using System;

namespace codebase.UI
{
    public class Label : Control
    {
        public int ForeColor;
        private string _Text;

        public string Text
        {
            get { return _Text; }
            set
            {
                _Text = value;
            }
        }

        public Label(int x, int y, int bg, int tc, string txt, Window parent)
        {
            Init(x, y, bg, tc, txt,parent);
        }

        void Init(int x, int y, int bg, int tc, string txt, Window parent)
        {
            Parent = parent;

            Left = x * Parent.Parent.screen.CharacterWidth;
            Top = y * Parent.Parent.screen.CharacterHeight;
            Text = txt;
            Height = Parent.Parent.screen.CharacterHeight;
            Width = txt.Length * Parent.Parent.screen.CharacterWidth;

            BackgroundColor = bg;
            ForeColor = tc;
        }

        protected override void DrawAll()
        {
            Draw();
        }

        protected override void Draw()
        {
            Parent.Parent.screen.DrawText(Text, Left + Parent.Left, Top + Parent.Top, false, BackgroundColor, ForeColor);
        }

        public void Clear(int len)
        {
            Parent.Parent.screen.DrawFilledRectangle(Left + Parent.Left, Top + Parent.Top, Left + (len*Parent.Parent.screen.CharacterWidth) + Parent.Left, Top + Height + Parent.Top, BackgroundColor);
        }
    }
}
